//
//  MineOrderQiangdanTableViewCell.m
//  PYWGetColor
//
//  Created by 杜文杰 on 2018/6/11.
//  Copyright © 2018年 dwj. All rights reserved.
//

#import "MineOrderQiangdanTableViewCell.h"
@interface MineOrderQiangdanTableViewCell()
@property (nonatomic, strong) UIImageView *titleImageView;
@property (nonatomic, strong) UILabel *titleLabel; // 标题

@property (nonatomic, strong) UILabel *serverTimeLabel; // 服务时间
@property (nonatomic, strong) UILabel *orderDistanceLabel; // 订单距离
@property (nonatomic, strong) UILabel *customerScoreLabel; // 用户评分
@property (nonatomic, strong) UIButton *makeSureOrderBtn; // 抢单
@end

@implementation MineOrderQiangdanTableViewCell
- (void)btnAction:(UIButton *)btn
{
    if ([btn isEqual:self.makeSureOrderBtn]) {
        NSLog(@"确认订单");
    }
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.separatorInset = UIEdgeInsetsZero;
        
        [self.contentView addSubview:self.titleImageView];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.serverTimeLabel];
        [self.contentView addSubview:self.orderDistanceLabel];
        [self.contentView addSubview:self.customerScoreLabel];
        [self.contentView addSubview:self.makeSureOrderBtn];
        
        __weak typeof(self)weakself = self;
        [self.titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakself.mas_top).offset(10 / WIDTH_6S_SCALE);
            make.left.equalTo(weakself.mas_left).offset(20 / WIDTH_6S_SCALE);
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(weakself.titleImageView.mas_centerY);
            make.left.equalTo(weakself.titleImageView.mas_right).offset(5 / WIDTH_6S_SCALE);
            make.width.mas_equalTo(200 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(20 / HEIGHT_6S_SCALE);
        }];
        [self.serverTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.titleImageView.mas_bottom).offset(20 / HEIGHT_6S_SCALE);
            make.left.equalTo(weakself.titleImageView);
            make.height.mas_equalTo(20 / HEIGHT_6S_SCALE);
            make.width.mas_equalTo(200 / WIDTH_6S_SCALE);
        }];
        [self.orderDistanceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakself.serverTimeLabel.mas_bottom).offset(10 / HEIGHT_6S_SCALE);
            make.left.equalTo(weakself.titleImageView);
            make.height.mas_equalTo(20 / HEIGHT_6S_SCALE);
            make.width.mas_equalTo(200 / WIDTH_6S_SCALE);
        }];
        [self.customerScoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakself.orderDistanceLabel.mas_bottom).offset(10 / HEIGHT_6S_SCALE);
            make.left.equalTo(weakself.titleImageView);
            //            make.height.mas_equalTo(20 / HEIGHT_6S_SCALE);
            make.width.mas_equalTo(230 / WIDTH_6S_SCALE);
        }];
        [self.makeSureOrderBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(weakself.mas_centerY).offset(15 / HEIGHT_6S_SCALE);
            make.right.equalTo(weakself.mas_right).offset(-20 / WIDTH_6S_SCALE);
            make.width.height.mas_equalTo(44 / WIDTH_6S_SCALE);
        }];
        self.makeSureOrderBtn.layer.cornerRadius = 22 / HEIGHT_6S_SCALE;
        self.makeSureOrderBtn.layer.masksToBounds = YES;
        [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakself.titleImageView.mas_top);
            make.left.right.equalTo(weakself);
            make.bottom.equalTo(weakself.customerScoreLabel.mas_bottom);
        }];
        
        
    }
    return self;
}
#pragma mark - init
- (UIImageView *)titleImageView
{
    if (!_titleImageView) {
        _titleImageView = [[UIImageView alloc]init];
        _titleImageView.backgroundColor = [UIColor clearColor];
        _titleImageView.image = [UIImage imageNamed:@"list_ico"];
    }
    return _titleImageView;
}
- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectZero];
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.textColor = getColor(blackColor);
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.font = DEF_FontSize_14;
        [_titleLabel sizeToFit];
        _titleLabel.text = @"水电维修工订单";
    }
    return _titleLabel;
}

- (UILabel *)serverTimeLabel
{
    if (!_serverTimeLabel) {
        _serverTimeLabel = [[UILabel alloc]initWithFrame:CGRectZero];
        _serverTimeLabel.backgroundColor = [UIColor clearColor];
        _serverTimeLabel.textColor = getColor(textColor);
        _serverTimeLabel.textAlignment = NSTextAlignmentLeft;
        _serverTimeLabel.numberOfLines = 0;
        _serverTimeLabel.font = DEF_FontSize_14;
        [_serverTimeLabel sizeToFit];
        _serverTimeLabel.text = @"服务时间:2018-01-06 上午";
    }
    return _serverTimeLabel;
}
- (UILabel *)orderDistanceLabel{
    if (!_orderDistanceLabel) {
        _orderDistanceLabel = [[UILabel alloc]initWithFrame:CGRectZero];
        _orderDistanceLabel.backgroundColor = [UIColor clearColor];
        _orderDistanceLabel.textColor = getColor(textColor);
        _orderDistanceLabel.textAlignment = NSTextAlignmentLeft;
        _orderDistanceLabel.numberOfLines = 0;
        _orderDistanceLabel.font = DEF_FontSize_14;
        [_orderDistanceLabel sizeToFit];
        _orderDistanceLabel.text = @"订单距离:全程500米";
    }
    return _orderDistanceLabel;
}
- (UILabel *)customerScoreLabel
{
    if (!_customerScoreLabel) {
        _customerScoreLabel = [[UILabel alloc]initWithFrame:CGRectZero];
        _customerScoreLabel.backgroundColor = [UIColor clearColor];
        _customerScoreLabel.textColor = getColor(textColor);
        _customerScoreLabel.textAlignment = NSTextAlignmentLeft;
        _customerScoreLabel.numberOfLines = 0;
        _customerScoreLabel.font = DEF_FontSize_14;
        [_customerScoreLabel sizeToFit];
        _customerScoreLabel.text = @"用户评分:5.0";
    }
    return _customerScoreLabel;
}
- (UIButton *)makeSureOrderBtn
{
    if (!_makeSureOrderBtn) {
        _makeSureOrderBtn = [[UIButton alloc]init];
        _makeSureOrderBtn.backgroundColor = getColor(mainColor);
        [_makeSureOrderBtn setTitleColor:getColor(whiteColor) forState:UIControlStateNormal];
        [_makeSureOrderBtn setTitle:@"抢单" forState:UIControlStateNormal];
        _makeSureOrderBtn.titleLabel.font = DEF_FontSize_12;
        [_makeSureOrderBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _makeSureOrderBtn;
}
@end


